home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / comm / ca29_3.zip / BBMAINT.CMD < prev    next >
OS/2 REXX Batch file  |  1992-03-24  |  9KB  |  263 lines

  1.     SET TTHRU OFF        ; Must be 1st line to suppress typethrough
  2.     LEGEND "BBS Maintenance ver 1.0"
  3. ;****    TRACE ON        ; Debugging
  4. ;
  5. ; ----- COM-AND BBS file maintenance script
  6. ;    Commenced: 11/90 R.McG
  7. ; -----------------------------------------------------------------------
  8. ;    Purpose:
  9. ;       The script, named BBSETUP.CMD, is executed to setup the BBS
  10. ;    script (version 1.1).  Setup 1) identifies the port and modem
  11. ;    control values, 2) identifies (and creates) the subdirs to be
  12. ;    used.  This script, BBMAINT.CMD is used to update relevant files.
  13. ; -----------------------------------------------------------------------
  14. ;    NOTE: This script expects to find a file named BBSDAT on 1) the
  15. ;    current subdirectory, 2) The COM-AND= environment var specified
  16. ;    subdirectory, or 3) the subdirectory where THIS script resides.
  17. ;    If this file is found, it will be overwritten subsequently.  If
  18. ;    NOT found, BBSDAT will be created on the subdir where COM-AND=
  19. ;    points.  S29 is used to keep the file name (subroutine INIT).
  20. ; -----------------------------------------------------------------------
  21. ;    NOTE: This script expects to find subroutine scripts named:
  22. ;    BBMAINT1 through BBMAINT4 on the same subdir as this script!
  23. ; -----------------------------------------------------------------------
  24. ;    Usage:
  25. ;       N99 -> Text attribute value
  26. ;       N98 -> Mainline cursor position
  27. ;       N97 -> Mainline cursor position
  28. ; -----------------------------------------------------------------------
  29. ;
  30. ;    Establish a DWINDOW, and change the text display to window default.
  31. ;    .. Save the previous text display attribute, for restoration later.
  32. ;
  33.     DWIND 1,2 22,78     ; Establish scrolling region
  34.     N99 = "_TEXT"           ; Save original text attr
  35.     SET TEXT "_DEFA"        ; Set text attr
  36. ;
  37. ;    Perform tasks
  38. ;
  39.     GOSUB Init        ; Setup initial values
  40.     GOSUB Files        ; Paint main screen
  41. ;
  42. ;    Exit the script
  43. ;
  44. Escape:
  45. Exit:
  46.     SET TEXT N99        ; Reset text attr finally
  47.     DWINDOW CLEAR        ; Clear any scrolling region
  48.     CLEAR            ; Clear entire text window
  49.     EXIT
  50. ; -----------------------------------------------------------------------
  51. ; ----- Subroutine: Init ->  Set initial values from BBSDAT
  52. ;    .. NOTE: S29 returns the file name to use for writes to BBSDAT
  53. ;
  54. Init:
  55.     S20 = "_PARM"(11:14)*","*"_PARM"(0:3) ; Port(4),speed(4)
  56.     S21 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M"  ; Standard MINIT for BBS
  57.     S22 = "\BBS"            ; Set to our subdirectory
  58.     S23 = "\BBS\FILES"      ; Set subdir for files
  59.     S24 = "\BBS\MAIL"       ; Set subdir for mail
  60.     S25 = "\BBS\BULLETIN"   ; Set subdir for bulletins
  61. ;
  62. ;    Replace above values from BBSDAT, if that script exists
  63. ;
  64.     S29 = ""                ; Make value null
  65.     IF ISSC "BBSDAT"        ; If file exists on dft subdir or COM-AND=
  66.        FCALL "BBSDAT"       ; .. execute it
  67.     ELSE
  68.        S10 = "_SCRIPT"      ; Get current script fname
  69.        GOSUB Parse_Fname    ; Extract drive:Subdir from name
  70.        S10 = S10*"\BBSDAT"  ; Make new name
  71.        IF ISSC S10        ; Invoke it if its THERE
  72.           FCALL S10     ; Invoke it
  73.           S29 = S10     ; Save for later
  74.           ENDIF
  75.        ENDIF
  76.     RETURN            ; Done init
  77. ; -----------------------------------------------------------------------
  78. ;    Subroutine: Parse drive:subdirectory from file name
  79. ;
  80. ;    S10 passes fully qualified name S10 returns drive:subdirectory
  81. ;                    S11 returns file name
  82. ;    N10,N11 are scratch values
  83. ; -----------------------------------------------------------------------
  84. ;
  85. Parse_Fname:
  86.     LENGTH S10 N10            ; Find length of string
  87.     FOR N11 = (N10-1),0,-1        ; Scan backwards through string
  88.         IF STRCMP S10(N11:N11) ":" or STRCMP S10(N11:N11) "\" GOTO PAFN100
  89.         ENDFOR
  90.     S11 = S10            ; No drive or path
  91.     S10 = ""                        ; Return null drive:path spec
  92.     RETURN
  93. ;
  94. ;    Extract drive and path from name; N11 points to ":" or "\"
  95. ;
  96. PAFN100:
  97.     S11 = S10(N11+1:N10)        ; Extract name portion
  98.     IF STRCMP S10(N11:N11) "\" DEC N11
  99.     S10 = S10(0:N11)        ; Save ":", remove last "\"
  100.     RETURN
  101. ; -----------------------------------------------------------------------
  102. ; ----- Error:    Open a window, display a message, and wait for keypress
  103. ;    S0 passes the error message
  104. ;
  105. Error:
  106.     WOPEN 10,10,12,70 (cont) Err_Esc
  107.     ATSAY 10,12 (cont) " Error "
  108.     ATSAY 11,12 (cont) S0(0:55); Max msg width 55 chars
  109.     ATSAY 12,26 (cont) " Press any key to continue "
  110.     ;
  111.     ;    Wait a keypress
  112.     ;
  113.     KEYGET S0        ; Wait for any key
  114.     WCLOSE
  115. Err_Esc:
  116.     RETURN
  117. ; -----------------------------------------------------------------------
  118. ; ----- Subroutine: Files ->  Update BBS files
  119. ;
  120. Files:
  121.     WOPEN 0,0 23,79 (defa) Main_Esc
  122.     ATSAY 0,2 (defa)   " BBS Files "
  123.     ATSAY 23,25 (defa) " Press ESC to cancel BBMAINT "
  124. ;
  125. ;    Fill in the current window
  126. ;
  127. File100:
  128.     CLEAR
  129.     LOCATE 2,2
  130.     MESS " 1) Update BBS User file"
  131.     MESS " 2) Update BBS File directory"
  132.     MESS " 3) Update BBS Mail listing"
  133.     MESS " 4) Update BBS Bulletin listing"
  134.  
  135.     IF ISSCRIPT "BBSetup" MESS " 5) Setup the BBS (default values)"
  136.     IF ISSCRIPT "BBS"     MESS " 6) Invoke the BBS"
  137.  
  138.     MESS "──────────────────────────────────── "
  139.     MESS " User file       is: "*S22*"\BBS-User"
  140.     MESS " Files directory is: "*S23*"\BBS-File"
  141.     MESS " Mail listing    is: "*S24*"\BBS-Mail"
  142.     MESS " Bulletin list   is: "*S25*"\BBS-Bull"
  143.     MESS " "
  144.     MESS "──────────────────────────────────── "
  145.     MESS "Note: Alt-Q to edit a file"
  146.     MESS "      Alt-F for a directory search"
  147.     MESS "      Alt-F10 to shell to DOS"
  148.     MESS " "
  149.     MESS "──────────────────────────────────── "
  150.     MESS "Select item (carriage return = previous): "
  151.     CURSOR N98 N97        ; Read current cursor
  152. ;
  153. ;    Wait for a keypress
  154. ;
  155. FILE200:
  156.     LOCATE N98 N97        ; Position cursor
  157.     KEYGET S0        ; Wait for it
  158.     SWITCH S0        ; Act according to keyget
  159.       CASE "1"
  160.            S0 = "BBMAINT1"  ; Invoke subsidiary - userids
  161.            GOSUB FCALL    ; Try to FCALL it
  162.            GOTO FILE200
  163.            ENDCASE
  164.       CASE "2"
  165.            S0 = "BBMAINT2"  ; Invoke subsidiary - files
  166.            GOSUB FCALL    ; Try to FCALL it
  167.            GOTO FILE200
  168.            ENDCASE
  169.       CASE "3"
  170.            S0 = "BBMAINT4"  ; Invoke subsidiary - mail
  171.            GOSUB FCALL    ; Try to FCALL it
  172.            GOTO FILE200
  173.            ENDCASE
  174.       CASE "4"
  175.            S0 = "BBMAINT3"  ; Invoke subsidiary - bulletin
  176.            GOSUB FCALL    ; Try to FCALL it
  177.            GOTO FILE200
  178.            ENDCASE
  179.       CASE "5"
  180.            IF ISSCRIPT "BBSetup"
  181.           S0 =    "BBSetup" ; Setup name
  182.           GOTO Execute    ; Execute the script
  183.           ENDIF
  184.            ENDCASE
  185.       CASE "6"
  186.            IF ISSCRIPT "BBS"
  187.           S0 =    "BBS"   ; Setup name
  188.           GOTO Execute    ; Execute the script
  189.           ENDIF
  190.            ENDCASE
  191.       CASE "0d"             ; c/r alone is exit
  192.            WCLOSE        ; Close window...
  193.            RETURN        ; Leave Main routine
  194.            ENDCASE
  195.       CASE "_NULL"          ; ESC -> Null
  196.            WCLOSE        ; Close window...
  197.            RETURN        ; Leave Main routine
  198.            ENDCASE
  199.       CASE "2100"           ; Alt-F
  200.            MANUAL "0x2100"  ; Perform Dir cmd
  201.            ENDCASE
  202.       CASE "1000"           ; Alt-Q
  203.            MANUAL "0x1000"  ; Edit a file
  204.            ENDCASE
  205.       CASE "7100"           ; Alt-F10
  206.            SHELL
  207.            DWINDOW 1,2,22,78; Reset dwindow after shell
  208.            LEGEND "_LEGEND" ; Redo the legend
  209.            ENDCASE
  210.       DEFAULT        ; None of the above
  211.            SOUND 100,100    ; Bronx cheer
  212.            ENDCASE
  213.       ENDSWITCH
  214.     GOTO File200        ; Repaint screen and ask again
  215. ;
  216. ;    Escape during main
  217. ;
  218. Main_Esc:
  219.     S0 = ""                 ; Blank entry
  220.     RETURN            ; And execute it
  221. ; -----------------------------------------------------------------------
  222. ; ----- EXECUTE: Close any open windows, reset defaults, and EXECUTE
  223. ;    a script (name passed in S0)
  224. ;
  225. Execute:
  226.     IF NOT ISSCRIPT S0 GOTO FILE100 ; Ignore nonexistant script
  227.     WCLOSE            ; Close open window
  228.     SET TEXT N99        ; Reset text attr finally
  229.     DWINDOW CLEAR        ; Clear any scrolling region
  230.     CLEAR            ; Clear entire text window
  231.     EXECUTE S0        ; Chain to the new script
  232. ; -----------------------------------------------------------------------
  233. ; ----- FCALL:    Open a script given a file name.  The script may be on
  234. ;    the current subdir, the COM-AND=subdir, OR on the same path as
  235. ;    this script itself.  S0 passes an UNqualified script